﻿using Core.SimpleTemp.Application;
using Core.SimpleTemp.Application.UserApp;
using Core.SimpleTemp.Mvc.Api.Internal;
using Core.Toolkit.Core.Api;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace Core.SimpleTemp.Api.Api
{
    /// <summary>
    /// 
    /// </summary>
    [Route("api/[controller]")]
    [EnableCors("any")]
    [ApiExplorerSettings(GroupName = "Sys")]
    [Authorize]
    [ApiController]
    public class IndexController : CoreApiController
    {
        private readonly SysLoginService _sysLoginService;

        /// <summary>
        /// 
        /// </summary>
        public IndexController(SysLoginService sysLoginService)
        {
            _sysLoginService = sysLoginService;
        }

        /// <summary>
        /// 根据当前登录用户获取菜单信息
        /// </summary>
        /// <returns></returns>
        [HttpGet("IndexData")]

        public async Task<IActionResult> IndexData()
        {
            var menuData = await _sysLoginService.GetMenusByCurrentUserAsync();
            return this.JsonSuccess(new { menuData, this.UserIdentity.Name });
        }
    }
}